#ifndef TOOLBAR_H
#define TOOLBAR_H
#include <QWidget>
#include <QFrame>
#include <QDialog>
#include <QHBoxLayout>
#include <QLabel>
#include <QDebug>
#include <QMouseEvent>
#include <QtMath>
#include <QPainter>
#include "utils/desktopinfo.h"
#include <QFont>
#include <gsettings.hpp>
#include <QGraphicsDropShadowEffect>
#include <QMessageBox>
#include <kborderlessbutton.h>
#include <kpushbutton.h>
#include "kpressbutton.h"
#include <libkydatacollect.h>
#include <QGSettings>
#include <QSettings>
#include <gsettings.hpp>

using namespace kdk;

class ToolBar : public QWidget
{
    Q_OBJECT
public:
    explicit ToolBar(QWidget *parent = nullptr);
    ~ToolBar();

    void changeStyle();
    QFrame *g_tooleWid = nullptr;                               //布局
    void platformType();
    void initControlQss(); //初始化布局

    void start();                 //开始
    void updateMicOption(bool isEnable);

protected:
    bool event(QEvent *event) override;
    int itemAt(const QPoint &p, QPoint &pShow);
    QString getTooltip(const int &index);

    //字体变化
    void initGsetting();
    void initLayout();
    void initConnect();
    void initMenu();
    void setBtnSize(QSize acturalSize);
    void setBtnIconSize(QSize iconSize);
    void setBtnIcon();
    void resumeStatus();
    void saveStatus();

private Q_SLOTS:
    void mouserec();
    void mouserecNav();
    void close();                 //关闭
    void setting();               //设置
    void soundrec();
    void soundrecNav();
    void time();
    void timeNav();
    void timeNone();
    void timeThree();
    void timeFive();
    void timeTen();
    void soundMic();
    void soundSys();
    void showMouse();
    void showMovePath();
    void clik();
    void keyrecord();
    void setFont();
    void longText(QLabel *nameC);

Q_SIGNALS:
    void showInfor();            //主界面显示信息栏
    void showSidebar();          //主界面显示相册
    void isDelete(bool isDel);   //判断删除
    void setFontSizeSignal(int); //字体变化
    void hideTwoBar();           //两栏隐藏，进入裁剪模式
    void showMarkingWid();
    void markUpdateImage(QString path);

    void sigCloseRecGui();
    void sigStartRec(int);
    void sigOpenSettingWid();
    void sigShowKey(bool);

private:
    QString widRadius = QString("16px");
    QHBoxLayout *m_toolLayout;

    QWidget *m_cursorWidget;
    QVBoxLayout *m_cursorVLayout;
    QHBoxLayout *m_cursorHLayout;
    KPressButton *m_cursorrec;                // 光标录制
    QLabel *m_cursorlabel;
    kdk::KBorderlessButton *m_cursorrecNav;             // 光标录制菜单导航
    QMenu *m_cursorrecMenu;
    QAction *m_actShowMouse;
    QAction *m_actShowMovePath;
    QAction *m_actClik;

    QWidget *m_soundWidget;
    QVBoxLayout *m_soundVLayout;
    QHBoxLayout *m_soundHLayout;
    KPressButton *m_soundrec;                // 声音录制
    QLabel *m_soundlabel;
    kdk::KBorderlessButton *m_soundrecNav;             // 声音录制菜单导航
    QMenu *m_soundrecMenu;
    QAction *m_actMic;
    QAction *m_actSysSound;

    QVBoxLayout *m_keyVLayout;
    QWidget *m_keyWidget;
    KPressButton *m_keyrec;                  // 按键录制
    QLabel *m_keylabel;

    QVBoxLayout *m_timeVLayout;
    QHBoxLayout *m_timeHLayout;
    QWidget *m_timeWidget;
    KPushButton *m_time;                    // 倒计时
    QLabel *m_timelabel;
    kdk::KBorderlessButton *m_timeNav;                 // 倒计时菜单导航
    QMenu *m_timeMenu;
    QAction *m_actNone;
    QAction *m_actThree;
    QAction *m_actFive;
    QAction *m_actTen;

    QLabel *m_line1;

    QVBoxLayout *m_settingVLayout;
    QWidget *m_settingWidget;
    KPushButton *m_setting;      // 设置
    QLabel *m_settinglabel;

    QVBoxLayout *m_closeVLayout;
    QWidget *m_closeWidget;
    KPushButton *m_close;        // 关闭
    QLabel *m_closelabel;

    QVBoxLayout *m_startVLayout;
    QWidget *m_startWidget;
    KPushButton *m_start;        // 开始
    QLabel *m_startlabel;

    QString nowThemeStyle;
    int m_countdown = 0;  // 倒计时/s
    bool m_isCursorRec = true;
    bool m_isShowMouse = true;
    bool m_isOpenSound = true;
    bool m_isOpenSysSound = true;
    bool m_isOpenMic = false;
    bool m_isKeyRec = false;
    bool m_isShowClick = false;
    bool m_isShowPath = false;
    DesktopInfo m_info;
    QGSettings *m_Data = nullptr;
    QGSettings *m_styleSettings = nullptr;
};

#endif // TOOLBAR_H
